home *** CD-ROM | disk | FTP | other *** search
/ funcom 2000 Presskit / 000721_1312 (fun.com).iso / funcom.dir / 00026_Script_Set Size behavior < prev    next >
Text File  |  2000-07-20  |  2KB  |  61 lines

  1.  
  2.  
  3. -- Set Size behavior
  4.  
  5. -----------------------------------------------------------
  6. -- This behavior sets the size of a shape sprite in
  7. -- response to a sliderMove message from the slider 
  8. -- behavior. The message also contains a value between 0  
  9. -- and 100 representing the slider's current position.
  10. --
  11. -- You attach this behavior to a shape sprite.
  12. --
  13. -- David Benman 11/97
  14. -----------------------------------------------------------
  15.  
  16. -- pControlButtonName - The name of the button that
  17. -- controls this behavior
  18. -- pStartWidth - The width of this sprite when the sprite
  19. -- begins
  20. -- pStartLoc - A point representing the starting position
  21. -- of this sprite
  22. property pControlButtonName, pStartWidth, pStartLoc
  23.  
  24.  
  25. -- This handler initializes the width, location, and
  26. -- control button properties.
  27. on beginSprite me
  28.   set currentSprite to the spriteNum of me
  29.   set pStartWidth to the width of sprite currentSprite
  30.   set pstartLoc to the loc of sprite the spriteNum of me
  31.   set pControlButtonName to "track"
  32. end
  33.  
  34.  
  35. -- This handler responds to a sliderMove message by
  36. -- changing the sprite's size. The size changes 
  37. -- when the behavior sending the message is the controlling
  38. -- button for this behavior.
  39. on sliderMove me, messageSenderName, ratio
  40.   
  41.   -- Resizes then moves the shape sprite to keep it 
  42.   -- centered. Scales width and height equally
  43.   if messageSenderName = pControlButtonName then
  44.     set currentSprite to the spriteNum of me
  45.     
  46.     -- Resizes sprite
  47.     set newDimension to pStartWidth + (ratio - 25) * 0.3
  48.     set the width of sprite currentSprite to newDimension
  49.     set the height of sprite currentSprite to newDimension
  50.     
  51.     -- Centers sprite
  52.     set offset to (ratio - 25) * 0.3 * 0.5
  53.     set newPoint to point(offset, offset)
  54.     set newLoc to  pStartLoc - newPoint
  55.     set the loc of sprite currentSprite to newLoc
  56.     
  57.   end if
  58.   
  59. end
  60.  
  61.